/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
<template>
  <div class="list-model">
    <div class="table-box">
      <!-- <el-table :data="list" size="mini" style="width: 100%">
        <el-table-column type="index" :label="$t('#')" width="50"></el-table-column>
        <el-table-column prop="type" label="算力类型"></el-table-column>
        <el-table-column prop="provider" label="数据中心"></el-table-column>
        <el-table-column prop="resourceType" label="资源型号"></el-table-column>
        <el-table-column prop="cpu" label="总核数"></el-table-column>
        <el-table-column prop="count" label="调用次数"></el-table-column>
        <el-table-column prop="createTime" label="创建时间"></el-table-column>
      </el-table> -->
      <el-table :data="list" size="mini" style="width: 100%">
        <el-table-column type="index" :label="$t('#')" width="80"></el-table-column>
        <el-table-colum prop="groupName" label="分组名称"></el-table-colum>
        <el-table-column prop="type" label="名称/id"></el-table-column>
        <el-table-column prop="IP" label="IP地址"></el-table-column>
        <el-table-column prop="createTime" label="部署时间"></el-table-column>
        <el-table-column prop="cpu" label="核数"></el-table-column>
        <el-table-column prop="usedCpu" label="已使用核数"></el-table-column>
        <el-table-column prop="usedMemory" label="已使用内存"></el-table-column>
        <el-table-column prop="status" label="状态"></el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  import { mapActions } from 'vuex'
  import _ from 'lodash'
  export default {
    name: 'environment-list',
    data () {
      return {
        list: []
      }
    },
    props: {
      environmentList: Array,
      pageNo: Number,
      pageSize: Number
    },
    methods: {
      ...mapActions('router', ['deleteRoute']),
      _onConditions (o) {
        this.searchParams = _.assign(this.searchParams, o)
        this.searchParams.pageNo = 1
      },
      _page (val) {
        this.searchParams.pageNo = val
      },
      _pageSize (val) {
        this.searchParams.pageSize = val
      },
      _delete (item, i) {
        this.deleteRoute({
          id: item.id
        }).then(res => {
          let newList = []
          this.list.forEach(item => {
            if (item.id !== i) {
              newList.push(item)
            }
          })
          this.list = newList
          this.$message.success(res.msg)
        }).catch(e => {
          this.$message.error(e.msg || '')
        })
      },
      _edit (item) {
        this.$emit('on-edit', item)
      }
    },
    watch: {
      environmentList (a) {
        this.list = []
        setTimeout(() => {
          this.list = a
        })
      }
    },
    created () {
      this.list = this.environmentList
    },
    mounted () {
    },
    components: {}
  }
</script>
<style lang="scss" scoped>
.font-class-green{
  color: #34A900 !important;
}
</style>
